package org.example.common;

import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class Config {

    private static Map<String,String> map = new HashMap<>();

    static{
        try(InputStream inputStream = Config.class.getResourceAsStream("/application.properties")){
            Properties properties = new Properties();
            properties.load(inputStream);

            Enumeration<?> enumeration = properties.propertyNames();
            while (enumeration.hasMoreElements()) {
                String key = (String) enumeration.nextElement();
                String val = properties.getProperty(key);
                map.put(key,val);
            }
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    public static String get(String key){
        return map.get(key);
    }
}
